home *** CD-ROM | disk | FTP | other *** search
Text File | 1988-04-24 | 2.3 KB | 105 lines | [TEXT/MPS ] |
- (*****************************************************
- Pop-up Menu Example
- *****************************************************)
-
- PROGRAM PopMenus;
-
- USES MemTypes,
- Quickdraw,
- OSIntf,
- ToolIntf,
- PackIntf;
-
- CONST
- myDLOGid = 128; { DLOG resource ID }
-
- Activate = 2; { Activate button }
- PopMenu1 = 3; { popMenu control 1 }
- PopMenu2 = 4; { popMenu control 2 }
- PopMenu3 = 5; { popMenu control 3 }
-
- ON = 0; { for HiliteControl }
- OFF = 255; { for HiliteControl }
-
-
- VAR
- myDialog: DialogPtr; { our test dialog }
- itemHit: INTEGER; { user's choice }
- state: INTEGER; { ON or OFF }
-
-
-
-
- (*****************************************************
- doHitActivate: Toggles the activation state of the
- popMenu control. Also toggles the Activate
- button's title (Activate <=> Deactivate).
- *****************************************************)
-
- PROCEDURE doHitActivate(dPtr: DialogPtr;
- VAR state: INTEGER);
- VAR
- ik: INTEGER;
- ih: Handle;
- ib: Rect;
-
- BEGIN
- { get handle to Activate button }
- GetDItem(dPtr, Activate, ik, ih, ib);
-
- { toggle state variable and button title }
- if (state = ON) then
- begin
- state := OFF;
- SetCTitle(ControlHandle(ih), 'Activate');
- end
- else begin
- state := ON;
- SetCTitle(ControlHandle(ih), 'Deactivate');
- end;
-
- { toggle the popMenu controls' activation states }
- GetDItem(dPtr, PopMenu1, ik, ih, ib);
- HiliteControl(ControlHandle(ih), state);
-
- GetDItem(dPtr, PopMenu2, ik, ih, ib);
- HiliteControl(ControlHandle(ih), state);
-
- GetDItem(dPtr, PopMenu3, ik, ih, ib);
- HiliteControl(ControlHandle(ih), state);
-
- END; { doHitActivate }
-
-
-
- (*****************************************************
- Main
- *****************************************************)
-
- BEGIN
- { perform the ritual incantation }
- InitGraf(@thePort);
- InitFonts;
- FlushEvents(everyEvent, 0);
- InitWindows;
- InitMenus;
- TEInit;
- InitDialogs(NIL);
- InitCursor;
-
- { read in the dialog from its resource template }
- myDialog := GetNewDialog(myDLOGid, NIL,
- POINTER(-1));
-
- { cycle through ModalDialog() until itemHit = OK }
- REPEAT
- ModalDialog(NIL, itemHit);
-
- { if the user hit the activate button, toggle }
- IF (itemHit = Activate) THEN BEGIN
- doHitActivate(myDialog, state);
- END;
- UNTIL itemHit = OK;
-
- DisposDialog(myDialog);
- END. { program PopMenus }